package com.authine.cloudpivot.ext.controller;

import com.authine.cloudpivot.web.api.utils.HttpClientUtils;
import com.authine.cloudpivot.web.api.view.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author yihang.xu
 */
@RestController
@RequestMapping("/api/toEhr")
@Slf4j
public class EhrController {


    @Autowired RestTemplate restTemplate;

    @Value("${custom.ehr.host}")
    private String ehrHost;

    @RequestMapping("/getBaseCity")
    public ResponseResult<Object> getBaseCity(@RequestParam("userid") String userid ){
        log.info("》》》》》》》进入ehr control");
        String url = ehrHost+"/ehr/cloudpivot/employee/baseCity?hOrgUserId="+userid;
        String  syncRst = HttpClientUtils.doGet(url);
        log.info("》》》》》调用ehr 接口返回 {}", syncRst);
        return ResponseResult.builder().data(syncRst).errcode(0L).errmsg("SUCCESS").build();
    }


//    public static void main(String[] args) {
//        String url = "http://ystest-daily1.web.wz-inc.com/ehr/cloudpivot/employee/baseCity?hOrgUserId=09ffd92b61784a60b0bdcd1a24f54ab9";
//        String  syncRst = HttpClientUtils.doGet(url);
//        System.out.println(syncRst);
//    }

}
